package simulation;

import java.util.ArrayList;

import streaming.Host;

public class MessageToComparatorModule implements EventHandler {

	String messageType;
	ArrayList<Integer> chunksToBeCompared;
	Host destination;
	
	public MessageToComparatorModule(String messageType, Host destination, ArrayList<Integer> chunkToBeCompared){
		this.setMessageType(messageType);
		this.chunksToBeCompared = chunkToBeCompared;
		this.setDestination(destination);
		
		double latency = 0.05; // TODO THIS IS A TEMPORARY VALUE, ONLY FOR TEST PURPOSE. SAME VALUE AS GETLATENCY() ON OVERLAY CLASSS
		
		// Put receipt of packet in the queue
		Simulator sim = Simulator.getInstance();
		sim.addEvent(sim.getTime() + latency, this) ;
	}

	
	public void run(double time) {
		if (this.getMessageType().equals("chunksToBeCompared")){
			this.getDestination().getComparatorModule().handleTrackerChunksInfo(this.getChunksToBeCompared());
		}
	}
	
	public String getMessageType() {
		return messageType;
	}

	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}

	public ArrayList<Integer> getChunksToBeCompared() {
		return chunksToBeCompared;
	}

	public void setChunkToBeCompared(ArrayList<Integer> chunksToBeCompared) {
		this.chunksToBeCompared = chunksToBeCompared;
	}

	public Host getDestination() {
		return destination;
	}

	public void setDestination(Host destination) {
		this.destination = destination;
	}
}
